package de.velvettear.bruteforce.util;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Timestamp {
 
	public static String format(BigDecimal milliseconds) {
		String hms = "n/a";
		
		try {
			long time = milliseconds.longValue();
			
			long seconds = (long) (time / 1000) % 60 ;
			long minutes = (long) ((time / (1000*60)) % 60);
			long hours   = (long) ((time / (1000*60*60)) % 24);
			
			hms = hours + "h " + minutes + "m " + seconds + "s";
		} catch (Exception e) {
			Log.error(e);
		}
		
		return hms;
	}		
	
	public static String getSimple() {
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
		return sdf.format(new Date());
	}
	
	public static String getFormatted() {
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
		return "[" + sdf.format(new Date()) + "]";
	}
	
	public static String getUnformatted() {
		SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy HHmmss");
		return "[" + sdf.format(new Date()) + "]";
	}
	
}
